//
//  IMPreviewFileController.m
//  wanzhaoIM
//
//  Created by wanzhao on 15/7/17.
//  Copyright (c) 2015年 liuyuantao. All rights reserved.
//

#import "IMPreviewFileController.h"
#import "JKAlertDialog.h"

@interface IMPreviewFileController ()<UIWebViewDelegate,UIScrollViewDelegate>

@property (nonatomic, weak) UIWebView *webView;

@end

@implementation IMPreviewFileController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGBCOLOR(0xf3, 0xf3, 0xf3);
    [self.navigationController setNavigationBarHidden:NO];
    [self.navigationItem setHidesBackButton:YES];
    [self.navigationItem setNewTitleCenter:@"查看文件"];
    
    UIWebView *webView = [[UIWebView alloc] init];
    webView.delegate = self;
    webView.scrollView.showsHorizontalScrollIndicator = NO;
    webView.scrollView.showsVerticalScrollIndicator = NO;
    webView.scrollView.backgroundColor = ClearColor;
    webView.scalesPageToFit = YES;
    
    webView.backgroundColor = ClearColor;
    self.webView = webView;
    
    
    [self.view addSubview:webView];
    NSURL *url = [NSURL URLWithString:self.filePath];
    [webView loadRequest:[[NSURLRequest alloc] initWithURL:url]];
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
//    JKAlertDialog *alert = [[JKAlertDialog alloc]initWithTitle:@"" message:@"加载文件失败！！"];
//    [alert addButton:Button_OK withTitle:@"确定" handler:^(JKAlertDialogItem *item) {
//        
//    }];
//    
//    [alert show];

}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
